﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using nplJobsCommon.Common;
using nplJobs.DB;
using System.Data;


namespace nplJobsDAL.Select
{
    public class SelectPostedJob
    {
        public static List<Job> GetList(Job obj, string strMode)
        {
            try
            {
                CustomParameterList cpList = new CustomParameterList();

                cpList.Add(new CustomParameter("@JobId", obj.JobID, DbType.Int32));
                cpList.Add(new CustomParameter("@JobTitle", obj.JobTitle, DbType.String));
                cpList.Add(new CustomParameter("@JobCategory", obj.JobCategory, DbType.String));
                cpList.Add(new CustomParameter("@JobType", obj.JobType, DbType.String));
                cpList.Add(new CustomParameter("@Skills", obj.Skills, DbType.String));
                cpList.Add(new CustomParameter("@Qualifications", obj.Qualifications, DbType.String));
                cpList.Add(new CustomParameter("@LocationID", obj.CityID,DbType.String));
                cpList.Add(new CustomParameter("@strMode", strMode, DbType.String));

                object paramval = null;
                DBHelper db = new DBHelper();
                DataTable dt = db.ExecuteQueryToDataTable(cpList.ParameterNames, cpList.ParameterValues, cpList.ParameterTypes, ref paramval, null, "spPostedJobSearch");

                List<Job> results = new List<Job>();
                foreach (DataRow dr in dt.Rows)
                {
                    Job objCity = new Job();

                    MapperBase.GetInstance().MapItem(objCity, dr); ;
                    results.Add(objCity);
                }
                return results;

            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }
    }
}
